<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>保险违约金扣除记录表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">&emsp;&emsp;
                    </div>
                    <div class="label">支付表号</div>
                    <div class="field">
                        <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>

                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <span id="flowStartBtn" onclick="flowStartBtn();"class="sq-button sq-button-round">转正常</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,
    callback=null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/insurance/insFeeDeductRec/initList.do',
            method: 'get',
            columns: [
				{display: '客户名称', name: 'cstNm', minWidth: 100, align: 'left', enabledSort: false},
				{display: '支付表号', name: 'paySchNo', minWidth: 100, align: 'left', enabledSort: false,
					render: function (rowdata, index, value) {
                        return '<a href="javascript:showPaySchDetail('+rowdata.paySchId+')"'+'class="link">'+rowdata.paySchNo+'</a>';
                    }
				},
				{display: '扣除金额', name: 'deductAmt', minWidth: 100, align: 'left', enabledSort: false,
					render:function(rowdata,index,value){
                        return '&yen;'+FormatMoney(rowdata.deductAmt/100);
                    }
				},
				{display: '扣除资金状态', name: 'deductStsNm', minWidth: 100, align: 'left', enabledSort: false},
				{display: '资金类型', name: 'feeTypNm', minWidth: 100, align: 'left', enabledSort: false},
				{display: '处理方式', name: 'handleWayNm', minWidth: 100, align: 'left', enabledSort: false},
				{display: '处理时间', name: 'crtTm', minWidth: 100, align: 'left', enabledSort: false,render:renderDate},
				{display: '操作人', name: 'crtUsrNm', minWidth: 100, align: 'left', enabledSort: false},
				{display: '保单止保时间', name: 'plcEndTm', minWidth: 100, align: 'left', enabledSort: false,render:renderDate},
				{display: '保单性质', name: 'plcPropNm', minWidth: 100, align: 'left', enabledSort: false},
				{display: '备注', name : 'deductRem', minWidth: 100, align: 'left', enabledSort: false},
				{display: '起租日期', name: 'lsDt',minWidth: 100, align: 'left', enabledSort: false,render:renderDate},
				{display: '融资期限', name: 'lsPd',minWidth: 100, align: 'left', enabledSort: false}
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();
        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });
        
        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });
        callback = function () {
            grid.reload();
        };
    });
 	 //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
 	
    function flowStartBtn() {
        var selectedRows = grid.getSelectedRows();
        if (selectedRows.length != 1) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
            return;
        }
        var deductStsCd = selectedRows[0].deductStsCd;
        var InsFeeDeductRecId = selectedRows[0].id;
        if (deductStsCd == "2") {
            $.ligerDialog.SQalert({content: "审核中,不允许多次发起流程.", SQ_type: "warning"});
            return;
        } 
        if (deductStsCd == "3") {
        	 $.ligerDialog.SQalert({content: "已转正常,不允许多次发起流程.", SQ_type: "warning"});
        	 return;
        }
        
        $.ligerDialog.confirm(FlowConstant.FLOW_ADD_START_CONFIRM, function (flag) {
            if (flag == false) return;
            var wait_dialog = $.ligerDialog.SQalert({
                content: LogUtils.LOG_CMM_DATA_LOADING,
                SQ_type: "waitting",
                onClose: function () {
                }
            });
            $.ajax({
                type: 'post',
                dataType: 'json',
                url: '<%=path%>/insurance/insFeeDeductRec/addFlowStart.do?InsFeeDeductRecId=' + InsFeeDeductRecId,
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {//成功发起流程
                        UIUtils.alertSuccessHold1(msg.info);
                        grid.reload();
                    } else if (msg.success == 0) {//错误
                        UIUtils.alertErrorHold1(msg.info);
                    }

                }
            });
        });

    }
  //查看支付表明细
    function showPaySchDetail(paySchId){
        $.ajax({
            type: 'get',
            dataType: 'json',
            url: '<%=path%>/risk/ovdCollect/getPayInfo.do?paySchId='+paySchId,
            success: function (msg) {
                if (msg.success == 1) {
                    Add_navTab('tab_prj_quat_prps'+paySchId,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+msg.data.prjId+'&&id='+paySchId+'&&prjPrdDtlId='+msg.data.prjPrdDtlId+'&&prjPrdId='+msg.data.prjPrdId+'&&detailFlag=true');
                }
            }
        });
    }

</script>

</body>
</html>
